package one.deploy.config;

import lombok.Builder;
import lombok.Data;
import one.deploy.dto.ApplicationListResponse;

import java.util.List;
import java.util.Map;

public interface IServiceConfigReader {

    void reload();

    Config getConfig();

    List<App> getApps();

    App getApp(String name);

    Action getAction(String name, String commandKey);

    List<ApplicationListResponse.Instance> getInstances(String name);

    List<ApplicationListResponse.Instance> getInstances(IServiceConfigReader.App app);

    @Data
    @Builder
    class Config {
        private String workspacePath;
        private String configPath;
    }

    @Data
    class App {
        /**
         * 项目名称
         */
        private String name;
        /**
         * 项目路径
         */
        private String bootPath;
        /**
         * 最新版本地址
         */
        private String lastVersionUrl;
        /**
         * 实例获取地址
         */
        private String instanceUrl;
        /**
         * 操作列表
         */
        private Map<String, Action> actions;
        /**
         * 最新版本
         */
        private String version;
        /**
         * 是否更新
         */
        private boolean updateReload;
    }

    @Data
    @Builder
    class Action {
        private String name;
        private String txt;
        private String content;
    }

    @Data
    class AppInfo {
        private Application application;
    }

    @Data
    class Application {
        private String name;
        private List<ApplicationListResponse.Instance> instance;
    }
}
